#pragma once
#include "ResourceBase.h"

namespace mini
{
	struct ParticleCell
	{
		CPoint3F pos = { 0, 0, 0 };
		CPoint3F rotation = { 0, 0, 0 };
		CPoint3F scale = { 1,1,1 };
		CPoint4F color = { 1, 0, 0, 1 };
		float	 liveTime = 0;
	};

	class IParticleEmitterType
	{
	public:
		virtual void emitter() = 0;
		virtual void update(float fDeltaTime) = 0;
	};

	class CParticleEmitterType : public IParticleEmitterType, public CResourceBase
	{
		friend class CParticleEmitter;

	public:
		CParticleEmitterType();
		virtual ~CParticleEmitterType();
		virtual void emitter() override;
		virtual void update(float fDeltaTime) override;

		void setParticleSize(const CPoint3F& size);
		const CPoint3F& getParticelSize() const;

		void setName(const std::string& szName);
		const std::string& getName() const;
	

	protected:
		CPoint2I mCreateCount = { 0,1 };
		CPoint2I mLiveTime = { 0,0 };
		CPoint3F mParticleSize;
		CPoint3F mRandomPos = { 0,0,0 };
		CPoint3F mRandomScale = { 0,0,0 };
		CPoint3F mRandomRotation = { 0,0,0 };
		std::string mszName = "";
		float mSpeed = 0;
		int	 mMaxParticles = 0;

		std::list<ParticleCell*>	mFreePartices;
		std::list<ParticleCell*>	mLivePartices;
	};

	class CParticleEmitterWaterFall : public CParticleEmitterType
	{
	public:
		CParticleEmitterWaterFall();
		virtual ~CParticleEmitterWaterFall();
		virtual void update(float fDeltaTime);

	};
}